<div class="card">
  <div class="card-content">
    <div class="columns is-vcentered">
      <div class="column">
        <h2 class="subtitle">Requests Analysis</h2>
      </div>
      <div class="column is-narrow">
        <%= render "export" %>
      </div>
    </div>
    <table class="table is-fullwidth is-hoverable">
      <thead>
        <tr>
          <th colspan='3'>Name</th>
          <th colspan='3' class="attention">Percentile</th>
          <th colspan='3'>Average</th>
          <th colspan='3'>Slowest</th>
        </tr>
        <tr>
          <th data-sort="string">Controller#action</th>
          <th data-sort="string">Format</th>
          <th data-sort="int">Requests</th>
          <th data-sort="float" class="attention">P50</th>
          <th data-sort="float" class="attention">P95</th>
          <th data-sort="float" class="attention">P99</th>
          <th data-sort="float">Duration</th>
          <th data-sort="float">Views</th>
          <th data-sort="float">DB</th>
          <th data-sort="float">Duration</th>
          <th data-sort="float">Views</th>
          <th data-sort="float">DB</th>
        </tr>
      </thead>
      <tbody>
        <% @data.each do |e| %>
          <% groups = e[:group].split("|") %>
          <% c, a = groups[0].split("#") %>
          <tr>
            <td><%= link_to groups[0],  rails_performance.rails_performance_summary_path({controller_eq: c, action_eq: a}), remote: true %></td>
            <td><%= link_to groups[1].try(:upcase),  rails_performance.rails_performance_summary_path({controller_eq: c, action_eq: a, format_eq: groups[1]}), remote: true %></td>
            <td><%= e[:count] %></td>
            <td class="nowrap attention"><%= ms e[:p50_duration] %></td>
            <td class="nowrap attention"><%= ms e[:p95_duration] %></td>
            <td class="nowrap attention"><%= ms e[:p99_duration] %></td>
            <td class="nowrap"><%= ms e[:duration_average] %></td>
            <td class="nowrap"><%= ms e[:view_runtime_average] %></td>
            <td class="nowrap"><%= ms e[:db_runtime_average] %></td>
            <td class="nowrap"><%= ms e[:duration_slowest] %></td>
            <td class="nowrap"><%= ms e[:view_runtime_slowest] %></td>
            <td class="nowrap"><%= ms e[:db_runtime_slowest] %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
